import type { reactive } from 'vue'
import type { LDMessage, LDFile } from './struct'

export type { LDMessage, LDFile }

// 主题类型
export type LDTheme = 'light' | 'dark'

// 对话框状态类型
export interface LDState {
  editorText: ReturnType<typeof defineModel<string>>
  isSending: boolean
  messages: LDMessage[]
  files: LDFile[]
}

// 响应式包裹
export type LDStateReactive = ReturnType<typeof reactive<LDState>>

// 对话框配置
export interface LDConfig {
  visible: boolean
  theme: LDTheme
  maxFileCount: number
  maxPerFileSize: number
  maxTotalFileSize: number
}

// 响应式包裹
export type LDConfigReactive = ReturnType<typeof reactive<LDConfig>>

// 事件暴露
export interface LDEmits {
  (e: 'send', text: string, files: File[], append: (text: string) => void, done: () => void): void
  (e: 'stop'): void
  (e: 'theme', newTheme: LDTheme, oldTheme: LDTheme): void
  (e: 'upload-files', files: FileList): void
  (e: 'delete-file', file: File): void
  (e: 'clear-files', files: File[]): void
}

// 对话框事件传递类型
export type LDEvents = {
  send: (text: string, files: File[], append: (text: string) => void, done: () => void) => void
  stop: () => void
  theme: (newTheme: LDTheme, oldTheme: LDTheme) => void
  uploadFiles: (files: FileList) => void
  deleteFile: (file: File) => void
  clearFiles: (files: File[]) => void
}
